const {
    jira,
    user
  } = require('./Configs');

const {
    JIRA_HOST
  } = jira;

const TimeTool = require('./Tools/TimeTool');
const Promise = require('bluebird'); 
let request = require('request');
request = Promise.promisifyAll(request);

// var aryy1=[{"id":"1","name":"n1"},{"id":"2",'name':'n2'},{'id':'3','name':'n3'}];


// var aryy2=[ [{"id":"1","name":"n1"}], 
//             [{"id":"2",'name':'n2'}],
//             [{'id':'3','name':'n3'}]];

// console.log(`aryy2的类型${toString.call(aryy2)}`)

// aryy2.forEach(item=>{

//     item.forEach(item2=>{

//         console.log('item2=',item2.name)
//     })

//     return console.log('item=',item)
// })

// aryy1.forEach(item=>{



//     console.log(`name=${item.name},id=${item.id}`)

// })

// 过滤测试
// async function filterIDParms(id) {
//     let newarry=[];
//     let filterIDArry=[];
//     filterIDArry.push(id);

//     let extraArr = ['10902', '11103', '10500', '10903', '10202', '10203', '10908', '10200',
//         '10101', '11003', '10201', '10905', '10400', '11101', '11102', '10004', '10906', '10002',
//         '10401', '10600', '10904', '10403', '10802', '11000'
//     ];

//     filterIDArry.forEach(item => {
//          console.log('item=',item)
//         let isSkip = false;
//         for (let z = 0; z < extraArr.length; z++) {
//             if (extraArr[z] == item) {
//                  isSkip = true;
//             }
//         }
//         if (!isSkip) {
//           //  console.log('!isSkip', !isSkip)
//             newarry.push(item);
//         }
//         console.log('newarry', newarry)

//     })

//     return newarry;
//   }



//   async function parmsidi(){
//     let testarry=['10902','11103','9999','11000','8888']

//     for (let g of testarry ){

//         console.log('g=',g)

//         filterIDParms(g)

//     }
// }

// parmsidi()



// async function  testSet(arrid){


//     let nwearry=[]

//     arry2=['110','120','130','140']


//     arrid.forEach(element => {


//         for (let i of arry2){

//             if (element.id == i){

//                 console.log('id=',element.id)
//                 console.log('i=',i)
//                 nwearry.push(i)

//             }


//         }



//     });

//     console.log('nwearry',nwearry)

//     }


//     testSet([{id:'110',name:'name'},{id:'120',name:'name'},{id:'112',name:'name'}])
// const moment = require('moment');

//     function getDate (num = 29) {
//         let now = new Date().getTime();
//         console.log('now',now)
//         let date1 =  moment(now )//- (1000 * 60 * 60 * 24 * num)
//         console.log(`data1${date1}`)

//         let date = moment(now - (1000 * 60 * 60 * 24 * num)).format('YYYY-MM-DD');
//         console.log(`data${date}`)
//         return date;
//     }

// function  getDays(date) {
//     console.log('date|',date)

//     let start = new Date(date).getTime();
//     console.log('start|',start)



//     let now = new Date().getTime();
//     console.log('now|',now)

//     let days = parseInt((now - start) / (1000 * 60 * 60 * 24));
//     console.log('days|',days)
//     return days;
//     }


// //getDate()

// getDays(getDate())

let aryy1 = [{
    "x": "2018-07-17",
    "y": 73,
    "id": "10208"
}, {
    "x": "2018-07-18",
    "y": 25,
    "id": "10208"
}, {
    "x": "2018-07-19",
    "y": 3,
    "id": "10208"
}, {
    "x": "2018-07-20",
    "y": 3,
    "id": "10208"
}, {
    "x": "2018-07-21",
    "y": 0,
    "id": "10208"
}, {
    "x": "2018-07-22",
    "y": 0,
    "id": "10208"
}, {
    "x": "2018-07-23",
    "y": 2,
    "id": "10208"
}, {
    "x": "2018-07-24",
    "y": 17,
    "id": "10208"
}, {
    "x": "2018-07-25",
    "y": 27,
    "id": "10208"
}, {
    "x": "2018-07-26",
    "y": 7,
    "id": "10208"
}, {
    "x": "2018-07-27",
    "y": 0,
    "id": "10208"
}, {
    "x": "2018-07-28",
    "y": 26,
    "id": "10208"
}, {
    "x": "2018-07-29",
    "y": 0,
    "id": "10208"
}, {
    "x": "2018-07-30",
    "y": 4,
    "id": "10208"
}, {
    "x": "2018-07-31",
    "y": 22,
    "id": "10208"
}, {
    "x": "2018-08-01",
    "y": 3,
    "id": "10208"
}, {
    "x": "2018-08-02",
    "y": 36,
    "id": "10208"
}, {
    "x": "2018-08-03",
    "y": 41,
    "id": "10208"
}, {
    "x": "2018-08-04",
    "y": 50,
    "id": "10208"
}, {
    "x": "2018-08-05",
    "y": 0,
    "id": "10208"
}, {
    "x": "2018-08-06",
    "y": 10,
    "id": "10208"
}, {
    "x": "2018-08-07",
    "y": 5,
    "id": "10208"
}, {
    "x": "2018-08-08",
    "y": 16,
    "id": "10208"
}, {
    "x": "2018-08-09",
    "y": 8,
    "id": "10208"
}, {
    "x": "2018-08-10",
    "y": 20,
    "id": "10208"
}, {
    "x": "2018-08-11",
    "y": 0,
    "id": "10208"
}, {
    "x": "2018-08-12",
    "y": 0,
    "id": "10208"
}, {
    "x": "2018-08-13",
    "y": 0,
    "id": "10208"
}, {
    "x": "2018-08-14",
    "y": 0,
    "id": "10208"
}, {
    "x": "2018-08-15",
    "y": 0,
    "id": "10208"
}];



//   for (let i=0; i<aryy1.length ;i++){

//    let  y1=aryy1[i]
//     console.log('y',y1)
//   }
// let sum=0;
// let max=0;
// for (let index in aryy1) {



//     if(aryy1[index].y>max){

//         max= aryy1[index].y
//         console.log('max1',max)
//     }
   
    
//    // console.log(' max',max)
// }

// const moment = require('moment');

// function getEachMonthDays(){

//     let monthStartAndEnd=[]
//     for (let m =1;m<=12;m++){
//         let firstDay = new Date(new Date().getFullYear(), m - 1, 1);
//         let firstDayFormat=moment(firstDay).format('YYYY-MM-DD');
//         let lastDay = new Date(new Date().getFullYear(), m, 0);
//         let lastDayFormat=moment(lastDay).format('YYYY-MM-DD');

//         monthStartAndEnd.push({
//           m:m,
//           firstDay:firstDayFormat,
//           lastDay:lastDayFormat
//         })

//     }

//     return monthStartAndEnd


//   }

//   let a =getEachMonthDays()
//   console.log(a)




//   class abc{
//   async  getBugAllMonthTotalBug(){

//     const newlyCreated = '%e6%96%b0%e5%88%9b%e5%bb%ba'
//     const processing = '%e5%a4%84%e7%90%86%e4%b8%ad'
//     const hang = '%e6%8c%82%e8%b5%b7'
//     const ProblemClosed = '%e9%97%ae%e9%a2%98%e5%85%b3%e9%97%ad'

//     let getEachMonthDaysArray = TimeTool.getEachMonthDays()
//     let sumallMonothBugtotal = []

      
//       for (let i of getEachMonthDaysArray) {
        
//         let api = `${JIRA_HOST}/rest/api/2/search?jql=project =
//             in ('10208','10700','11100','10300','10204','10907','10100','11104','11106','11107','10901', '11105', '11004', '10704') AND status 
//             in (${newlyCreated}, ${processing},${hang}, ${ProblemClosed}) AND created >= ${i.firstDay} AND created <= ${i.lastDay}`
//         let res = await request.getAsync(api, user)
//         let ret = JSON.parse(res.body) // 必须转化成json 才能对象取值
//         let total = ret.total

//         sumallMonothBugtotal.push({
//             x: i.m + '月',
//             y: total
    
//           })
//       }


//     return sumallMonothBugtotal


//   }

// }

//   let  bb=new abc()
//   let cc =bb.getBugAllMonthTotalBug()
//   console.log('cc',cc)


const aryy5 = [{
        real_name: '何景涛',
        acition: null,
        option_object: '提交测试',
       
    },
    {
        real_name: 'Jonny',
        acition: 'v_delete',
        option_object: 'v666',
     
    },
    {
        real_name: 'Jonny',
        acition: 'delete',
        option_object: 'v_1010',
       
    },
    {
        real_name: 'Jonny',
        acition: 'v_insert',
        option_object: 'V9898',
      
    },
    {
        real_name: 'Jonny',
        acition: 'v_update',
        option_object: 'v_1010,2018-12-20,2018-12-20,9999',

    },
    {
        real_name: 'Jonny',
        acition: 'v_update',
        option_object: 'v666,2018-12-20,2018-12-21,v666,666他他哥哥嘎嘎嘎',
        
    },
    {
        real_name: 'Jonny',
        acition: 'v_update',
        option_object: 'v_2222018-12-202018-12-21v_222888888',
       
    },
    {
        real_name: 'Jonny',
        acition: 'v_insert',
        option_object: 'v_1000',
     
    },
    {
        real_name: 'Jonny',
        acition: 'delete',
        option_object: 'MK_1111111111111111111111',
        
    },
    {
        real_name: 'Jonny',
        acition: 'update',
        option_object: '99999999999999',
       
    },
    {
        real_name: 'Jonny',
        acition: 'insert',
        option_object: 'MK_1111111111111111111111',
       
    }
]

